const fs = require('fs')
const http = require('http')
const path = require('path')

const server = http.createServer()
server.on('request', (req, res) => {
  let url = req.url
  if (url === '/') url = '/index.html'
  const absoluteUrl = path.join(__dirname, '/clock', url)
  if (url == '/favicon.ico') return
  fs.readFile(absoluteUrl, 'utf8', (err, data) => {
    if (err) res.end('404')
    res.end(data)
  })
})
server.listen(80, () => {
  console.log('启动成功！')
})